﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows;
using System.Windows.Input;

using ASApplication;

using ASWPF;

using FXnaMet;

using FXnaAppBase;
using FXnaAppBaseWpf;




namespace ASPresentation
{

    /// <summary>
    /// 专门用于管理run相关的command
    /// </summary>
    public class DosRunCommandsBinder
    {



        static RoutedCommand runAermod = new RoutedCommand();

        public static RoutedCommand RunAermod
        {
            get { return DosRunCommandsBinder.runAermod; }
           
        }

      


          
           /// <summary>
        /// 将命令绑定到窗体
        /// </summary>
        /// <param name="window"></param>
        public static void BindCommandsToWindow(Window window)
        {


            CommandBinding cbRunAermod = new CommandBinding();
            cbRunAermod.Command = DosRunCommandsBinder.runAermod;
            cbRunAermod.CanExecute += new CanExecuteRoutedEventHandler(cbRunAermod_CanExecute);
            cbRunAermod.Executed += new ExecutedRoutedEventHandler(cbRunAermod_Executed);

            window.CommandBindings.Add(cbRunAermod);



        }


        static void cbRunAermod_Executed(object sender, ExecutedRoutedEventArgs e)
        {

            AermodRunData data=new AermodRunData ();



            string workPath=ProjectService.CurrentService.GetProjPath(ProjPath.Solutions);




            //AermapRC map = new AermapRC("aermap.exe","aermap.inp",workPath);

            //data.Commands.Add(map);



            //这里需要注意，这里是分步骤运行的，但是文件名称却是一个，听夸张的
            //这里的2 3 表示的是序号。


            AermetRC met2 = new AermetRC("aermet.exe", "aermet.inp", workPath,true);

            data.Commands.Add(met2);



            AermetRC met3 = new AermetRC("aermet.exe", "aermet.inp", workPath,false);

            data.Commands.Add(met3);




            //AermodRC mod = new AermodRC("aermod.exe", "aermod.inp", workPath);

            //data.Commands.Add(mod);



            //这里可能还缺少多方案有关的调度，另外由于aermod本身一次只支持一个污染物，需要人工的添加调度的代码，这样就增加了难度



         

            winRun run=new winRun (data);

            if (run.ShowDialog()==true)
	        {

                

		 
	        }

  


           

        }

        static void cbRunAermod_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (!ProjectService.CurrentService.BNullProj)
            {
                e.CanExecute = true;
                e.Handled = true;

            }

        }




    }
}
